package jsonprotocol

import (
	"time"
)

// Point defines values that will be written in line protocol.
type Point interface {
	// Byte slice representing the series key for a point.
	Series() []byte

	// Slice of Field (alais for io.WriterTo) interfaces.
	Fields() []Field

	Time() *Timestamp
	SetTime(time.Time)

	// CloneFields 克隆字段
	CloneFields() map[string]interface{}
	// Update is intended to be used to mutate field values.
	Update(fields map[string]interface{})
}

// func WritePoint(pt Point) map[string]interface{}{
// 	fields := pt.CloneFields()
// 	for k, v := range fields {
// 		switch val := v.(type) {
// 		case int:
// 			fields[k] = val + 1
// 		case float64:
// 			fields[k] = val + (rand.Float64()-0.5)*0.1 // ±5% 波动
// 		case bool:
// 			fields[k] = !val
// 		}
// 	}
// 	doc := map[string]interface{}{
// 		"tags":      pt.Tags,
// 		"fields":    fields,
// 		"timestamp": ts.UTC(),
// 	}
// 	return doc
// }
